<template>
    <el-tooltip placement="top-start" :content="`远程从大乐透官方获取数据。上次刷新：${dltDataModel.getRefreshTime(true)}`">
        <el-button type="warning" size="small" icon="Refresh" plain round :loading="isLoading"
            @click="onRefresh()"></el-button>
    </el-tooltip>
</template>

<script setup>
/**
 * 缓存数据切换组件
 */
import { ElMessage } from 'element-plus';
import { ref } from 'vue';
import DltDataModel from '@/model/DltDataModel';

let dltDataModel = new DltDataModel();
const isLoading = ref(false);
const onRefresh = () => {
    isLoading.value = true;
    dltDataModel.loadData(true).then(() => {
        isLoading.value = false;
        ElMessage.success('刷新大乐透数据成功');
    }).catch(() => {
        isLoading.value = false;
    });
}
</script>